package day14_100;

/**
 * @ClassName Solution
 * @Description TODO DFS
 * @Author clockTown
 * @Date 2021/5/23 20:21
 * @Version 1.0
 */
public class Solution1 {
    public static boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null){
            return true;
        }
        if (p == null || q == null) {
            return false;
        }
        if (p.val != q.val){
            return false;
        }

        return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }

    //test
    public static void main(String[] args) {
        TreeNode p = new TreeNode(1);
        p.left = new TreeNode(1);
        System.out.println(p);

        TreeNode q = new TreeNode(1);
        q.right = new TreeNode(1);
        System.out.println(q);

        System.out.println(isSameTree(p, q));
    }
}
